package com.zzyl.nursing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zzyl.nursing.dto.NursingTaskDto;
import com.zzyl.nursing.dto.TaskDto;
import com.zzyl.nursing.vo.NursingTaskVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.service.INursingTaskService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 护理任务Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/nursing/nursingTask")
@Api(tags = "护理任务的接口")
public class NursingTaskController extends BaseController
{
    @Autowired
    private INursingTaskService nursingTaskService;

    /**
     * 查询护理任务列表
     */
    @ApiOperation("查询护理任务列表")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(NursingTaskDto dto)
    {
        List<NursingTaskVo> list = nursingTaskService.selectNursingTaskList(dto);
        return getDataTable(list);
    }


    /**
     * 获取护理任务详细信息
     */
    @ApiOperation("获取护理任务详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam(value = "护理任务ID", required = true)
            @PathVariable("id") Long id)
    {
        return AjaxResult.success(nursingTaskService.queryNursingTaskById(id));
    }


    /**
     * 取消护理任务
     */
    @ApiOperation("取消护理任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:edit')")
    @Log(title = "护理任务", businessType = BusinessType.UPDATE)
    @PutMapping("/cancel")
    public AjaxResult cancelNursingTask(@ApiParam(value = "护理任务实体")
            @RequestBody TaskDto taskDto)
    {
        return toAjax(nursingTaskService.cancelNursingTask(taskDto));
    }

    /**
     * 执行护理任务
     */
    @ApiOperation("执行护理任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:edit')")
    @Log(title = "护理任务", businessType = BusinessType.UPDATE)
    @PutMapping("/do")
    public AjaxResult startNursingTask(@ApiParam(value = "护理任务实体")
                                        @RequestBody TaskDto taskDto)
    {
        return toAjax(nursingTaskService.startNursingTask(taskDto));
    }

    /**
     * 护理任务改期
     */
    @ApiOperation("护理任务改期")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:edit')")
    @Log(title = "护理任务", businessType = BusinessType.UPDATE)
    @PutMapping("/updateTime")
    public AjaxResult updateTimeNursingTask(@ApiParam(value = "护理任务实体")
                                       @RequestBody TaskDto taskDto)
    {
        return toAjax(nursingTaskService.updateTimeNursingTask(taskDto));
    }

}
